home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15850 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: news.mindlink.net!news
  2. From: Allan_Nienhuis@mindlink.bc.ca (Allan Nienhuis)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: 2D pointer array to class overwritten
  5. Date: Mon, 08 Apr 1996 14:39:44 GMT
  6. Organization: MIND LINK! - British Columbia, Canada
  7. Message-ID: <4kb89l$2to@fountain.mindlink.net>
  8. References: <4k89ap$7fl@ctylnk.cityu.edu.hk> <9604071928.AA001og@lorelei.demon.co.uk>
  9. NNTP-Posting-Host: line013.abb.mindlink.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. John Croudy <john@lorelei.demon.co.uk> wrote:
  13.  
  14. >I'm sure I'm not the only one who spotted the [i,j] instead of [i][j].
  15.  
  16. >But why doesn't the compiler at least warn about this? I tried and
  17. >couldn't get a warning out of GNU.
  18.  
  19. This is rather cryptic :)  (also perfectly legal)
  20.  
  21. i is being evaluated, and it's evaluation is being discarded, then j
  22. is evaluated and used in the [] pointer reference.
  23.  
  24. consider this from the Borland vers 3.1 help file:
  25.  
  26.  
  27. ***************************************************
  28. Comma punctuator and operator     ( , )
  29.  
  30. The comma separates the elements of a function argument list.
  31.  
  32. The comma is also used as an operator in comma expressions. Mixing the
  33. two uses of comma is legal, but you must use parentheses to
  34. distinguish them.
  35.  
  36. Syntax
  37.  
  38. expression , assignment-expression
  39.  
  40. The left operand E1 is evaluated as a void expression, then E2 is
  41. evaluated to give the result and type of the comma expression. By
  42. recursion, the expression
  43.  
  44.  
  45. E1, E2, ..., En
  46.  
  47. results in the left-to-right evaluation of each Ei, with the value and
  48. type of En giving the result of the whole expression.
  49.  
  50. To avoid ambiguity with the commas used in function argument and
  51. initializer lists, parentheses must be used. For example,
  52.  
  53.  
  54. func(i, (j = 1, j + 4), k);
  55.  
  56. calls func with three arguments, not four. The arguments are i, 5, and
  57. k.
  58.  
  59. ***************************************************
  60.  
  61.